unit UdataMoudule;

interface

uses
  SysUtils, Classes, DB, ADODB;

type
  Tdm = class(TDataModule)
    ADOConn: TADOConnection;
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
     function Login(UserName,PassWord:string):Boolean;
  end;

var
  dm: Tdm;

implementation

{$R *.dfm}

procedure Tdm.DataModuleCreate(Sender: TObject);
begin
  ADOConn.Connected:=True;
end;

function Tdm.Login(UserName, PassWord:string): Boolean;
  var qry:TADOQuery;
begin
   
    qry:= TADOQuery.Create(nil);
    qry.Connection:=ADOConn;
    try
      qry.SQL.Text:='select count(*) as  d  from actor '
                    + ' where userName =:username and password=:password';
      qry.Parameters.ParamByName('username').Value:=UserName;
      qry.Parameters.ParamByName('password').Value:=PassWord;
      qry.Open;
      if qry.FieldByName('d').AsInteger>0 then
        Result:=True
      else
        Result:=false;

    finally
      qry.Free;
    end;

end;

end.
